﻿using sql_data_generator.FieldOptions;
using sql_data_generator.Generators;

namespace sql_data_generator.Randomizers
{
    class RandomizerIPv4Address : BaseRandomizer<FieldOptionsIPv4Address>, IRandomizer
    {
        private readonly RandomIntegerGenerator _firstOctet = new RandomIntegerGenerator(1, 0xff);
        private readonly RandomIntegerGenerator _otherOctets = new RandomIntegerGenerator(0, 0xff);

        public RandomizerIPv4Address(FieldOptionsIPv4Address options)
            : base(options)
        {
        }

        public object GetData()
        {
            return IsNull() ? null : string.Format("{0}:{1}:{2}:{3}", _firstOctet.Generate(), _otherOctets.Generate(), _otherOctets.Generate(), _otherOctets.Generate());
        }
    }
}